﻿namespace DomainServices.Tools
{
    using System;
    using System.ComponentModel.DataAnnotations;

    internal class EditableAttributeBuilder : StandardCustomAttributeBuilder
    {
        public override AttributeDeclaration GetAttributeDeclaration(Attribute attribute)
        {
            EditableAttribute attribute2 = (EditableAttribute) attribute;
            AttributeDeclaration declaration = new AttributeDeclaration(typeof(EditableAttribute));
            bool allowEdit = attribute2.AllowEdit;
            bool allowInitialValue = attribute2.AllowInitialValue;
            declaration.ConstructorArguments.Add(allowEdit);
            if (allowEdit != allowInitialValue)
            {
                declaration.NamedParameters.Add("AllowInitialValue", allowInitialValue);
            }
            return declaration;
        }
    }
}

